feat(risk): runtime-tunable risk controls#162
Open
FurkanEdizkan wants to merge 15 commits into
Open
Conversation
Approved brainstorming design: make the existing (but env-only, boot-time, disabled-by-default) RiskManager limits editable at runtime from the Settings UI. Engine reads limits from the settings store per tick; hybrid defaults (disabled, UI pre-fills recommended values); backward-compatible env fallback. Backtest simulation of limits deferred. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
TDD, bite-sized plan (7 tasks): store getters/setters, RiskManager.from_store with env fallback, per-tick engine read (injected override preserved), settings API read/update + validation, regenerated web client, Settings "Risk controls" card with hybrid pre-fills, and final verification. Derived from the approved 2026-07-02 design spec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tingsUpdate Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the engine's five global risk limits — stop-loss, take-profit, per-order notional cap, daily-loss limit, and drawdown kill switch — editable at runtime from the Settings UI, applied on the next engine tick, without an engine restart. The enforcement math in
trading/risk.pyis unchanged; this wires config, tuning, and visibility around it.appsettingsKV store (get/set_risk_*), read viaRiskManager.from_store(session)each tick. Falls back to envrisk_*for any unset limit, so existing env-configured deployments keep identical effective limits.GET /api/settingsexposes the fiverisk_*fields;PUT /api/settings/riskvalidates (ge=0, le=100on %;ge=0on amounts) and audits.Built via spec → plan → subagent-driven TDD (two-stage review per task). Design docs:
docs/superpowers/specs/2026-07-02-runtime-tunable-risk-controls-design.md,docs/superpowers/plans/2026-07-02-runtime-tunable-risk-controls.md.Test Plan
from_storeprecedence; per-tick enforcement + injected override; API read/update/validation; manual-order + AI-signal paths honor a stored cap (fail-before/pass-after verified)🤖 Generated with Claude Code